<?php

$PHPSESSID = @$_GET['PHPSESSID'];
$ReportToFilter = @$_GET['ReportToFilter'];

$fltrString = "";
$Fmly = @$_POST['Family'];
$Indv = @$_POST['Individual'];
$Indv_fltr = @$_POST['Individual_fltr'];
$Fmly_fltr = @$_POST['Family_fltr'];
//$Fltr = "';
$Fltr = @$_POST['filterdisplay'];
$Fmly_sql = "";
$Indv_sql = "";
$Fmly_sqla = "";
$Indv_sqla = "";
$BsubmitInd = FALSE;

echo '<div id="page_header">'."\n";
echo '<ul>'."\n";
echo '<li class="titlename2">Filter Report</li>'."\n";

echo '<li class="type2">Select options to filter the report by.</li>'."\n";
echo '</ul>'."\n";
echo '</div>'."\n";

echo '<div id="details-section">'."\n";



if (isset($_POST['submitData'])) { // if form has been submitted
    $BsubmitInd = TRUE;
    //echo "<pre>";
    //print_r($_POST);
    //echo "</pre>";
    if(isset($Fltr)) {
        foreach(@$Fltr as $keyF=>$valF) {
            $fltrString .="&amp;".$keyF."=".$valF;
        }
    } else {
        $fltrString ="";
    }


    //	echo "$fltrString <p>";
    //echo "Compile Indiviudal WHERE clause<p>";
    $Fmly_sql = "TRUE";
    $Indv_sql = "TRUE";
    $Fmly_sqla = "";
    $Indv_sqla = "";

    foreach($_POST as $key1=>$val1) {
        if($key1=="Family" OR $key1=="Individual") {
            foreach($val1 as $key2=>$val2) {
                if(strlen(trim($val2))>0 and $key1=="Family") {
                    $Fmly_sqla .= " AND UCASE(Family.$key2) LIKE UCASE('$val2') ";
                }
                if(strlen(trim($val2))>0 and $key1=="Individual") {
                    $Indv_sqla .= " AND Individual.$key2 LIKE '$val2' ";
                }
            }
        }

    }

    if(isset($Indv_fltr)) {
        //		echo "is set <p>";
        if($Indv_fltr['ChurchDirectory'] == "ALL") {
            $Indv_sqla = $Indv_sqla ;
        }
        if($Indv_fltr['ChurchDirectory'] == "Y") {
            $Indv_sqla .= " AND Individual.ChurchDirectoryIndicator = 'Y' ";
        }
        if($Indv_fltr['ChurchDirectory'] == "N") {
            $Indv_sqla .= " AND Individual.ChurchDirectoryIndicator = 'N' ";
        }


        if(@$Indv_fltr['YoungAdultIndicator'] == "ALL") {
            $Indv_sqla = $Indv_sqla ;
        }
        if(@$Indv_fltr['YoungAdultIndicator'] == "Y") {
            $Indv_sqla .= " AND Individual.YoungAdultIndicator = 'Y' ";
        }
        if(@$Indv_fltr['YoungAdultIndicator'] == "N") {
            $Indv_sqla .= " AND Individual.YoungAdultIndicator = 'N' ";
        }


        if($Indv_fltr['Baptism'] == "ALL") {
            $Indv_sqla = $Indv_sqla ;
        }

        if($Indv_fltr['Baptism'] == "Y") {
            $Indv_sqla .= " AND Individual.BaptismContactIndicator = 'Y' ";
        }
        if($Indv_fltr['Baptism'] == "N") {
            $Indv_sqla .= " AND Individual.BaptismContactIndicator = 'N' ";
        }
    }



    if(isset($Fmly_fltr)) {
        //		echo "is set <p>";
        if($Fmly_fltr['OutOfArea'] == "ALL") {
            $Fmly_sqla = $Indv_sqla ;
        }

        if($Fmly_fltr['OutOfArea'] == "Y") {
            $Fmly_sqla .= " AND Family.OutOfAreaIndicator = 'Y' ";
        }
        if($Fmly_fltr['OutOfArea'] == "N") {
            $Fmly_sqla .= " AND Family.OutOfAreaIndicator = 'N' ";
        }
    }






    if(strlen(trim($Indv_sqla))>0 ) {
        $Indv_sql = htmlentities(urlencode(trim($Indv_sql." ".$Indv_sqla)));
        //echo "$Indv_sql ";
        //exit;
    } else {
        $Indv_sql = "TRUE";
    }
    if(strlen(trim($Fmly_sqla))>0) {
        $Fmly_sql = htmlentities(urlencode(trim($Fmly_sql." ".$Fmly_sqla)));
    } else {
        $Fmly_sql = "TRUE";
    }

    echo '<p><a href="index.php?type=report&amp;view='.$ReportToFilter.'&amp;CSVOutput=FALSE&amp;XMLOutput=FALSE&amp;fmly_sql='.$Fmly_sql.'&amp;indv_sql='.$Indv_sql.$fltrString.'" rel="external" class="reportlink">Click here to open report '.$ReportToFilter.' as PDF document</a><br />'."\n";


    //	echo "<p><a href=\"reports/".$ReportToFilter."?fmly_sql=".$Fmly_sql."&indv_sql=".$Indv_sql.$fltrString."\" rel=\"external\" class=\"reportlink\">Click here to open report $ReportToFilter</a><br />\n";
    if(strlen($Indv_sql.$Fmly_sql)>0) {
        echo "Report is filtered by $Indv_sqla  $Fmly_sqla<br />\n";
        //	echo strlen($Fmly_sql)." - '$Fmly_sql'<p>";
        //	echo strlen($Indv_sql)." - '$Indv_sql'<p>";
    } else {
        echo "Report is not filtered<br />\n";
    }
} // end if submit
$linktoOpen = "?fmly_sql=".$Fmly_sql."&indv_sql=".$Indv_sql;



$linktoOpen = htmlentities(urlencode($linktoOpen));
$fltrString = htmlentities(urlencode($fltrString));

if (isset($_POST['submitData']) ) {
    echo '<script language="JavaScript" type="text/javascript">'."\n";
    echo 'openReport("reports/"'.$ReportToFilter.'","'.$linktoOpen.'","'.$fltrString.'", "'.$PHPSESSID.'" );'."\n";
    echo '</script>'."\n";
}


if (!isset($_POST['submitData']) or @$error_occurred == TRUE);
{	// if form hasn't been submitted

    echo '<form action="index.php?view=Reports_filter&amp;ReportToFilter='.$ReportToFilter.'&amp;PHPSESSID='.$PHPSESSID.'" method="post">'."\n";
    echo '<div id="viewDetailsC2">'."\n";

    //    echo '<table border="1" cellspacing="0" cellpadding="0"><tr><td>'."\n";
    echo '<p class="errmsg1">Filter Report Data : '.$ReportToFilter.'</p>'."\n";

    echo '<ul>'."\n";
    echo '<li class="viewDetailsHeader" title="'.trim($PACTS_cfg->getFieldDescription("Family", "ResidentialSuburb")).'">';
    echo 'Family ResidentialSuburb:</li>'."\n";
    $sql = "SELECT ResidentialSuburb FROM  `Family` WHERE ResidentialSuburb IS NOT NULL ";
    $sql .= "GROUP BY ResidentialSuburb ORDER BY  `ResidentialSuburb`  ASC ";
    echo '<li class="viewDetailsDataEdit">'."\n";
    echo $PACTS_cfg->getOptionList("Family[ResidentialSuburb]",$sql,"ResidentialSuburb",@$Fmly['ResidentialSuburb']);
    echo '</li>'."\n";
    echo '</ul>'."\n";


    echo '<ul>'."\n";
    echo '<li class="viewDetailsHeader" title="'.trim($PACTS_cfg->getFieldDescription("Family", "ResidentialPostcode")).'">';
    echo 'Family ResidentialPostcode:</li>'."\n";
    $sql = "SELECT ResidentialPostcode FROM  `Family` WHERE ResidentialPostcode IS NOT NULL ";
    $sql .= "GROUP BY ResidentialPostcode ORDER BY  ResidentialPostcode ASC ";
    echo '<li class="viewDetailsDataEdit">'."\n";
    echo $PACTS_cfg->getOptionList("Family[ResidentialPostcode]",$sql,"ResidentialPostcode",@$Fmly['ResidentialPostcode']);
    echo '</li>'."\n";
    echo '</ul>'."\n";

    echo '<ul>'."\n";
    echo '<li class="viewDetailsHeader" title="'.trim($PACTS_cfg->getFieldDescription("Individual", "RoleTypeCode")).'" >';
    echo 'Individual Role Type:</li>'."\n";
    echo '<li class="viewDetailsDataEdit">'."\n";
    echo "".$PACTS_cfg->getLookupTableHTML("RoleTypeCode","Individual[RoleTypeCode]",@$Indv['RoleTypeCode'],"1");
    echo '</li>'."\n";
    echo '</ul>'."\n";

    echo '<ul>'."\n";
    echo '<li class="viewDetailsHeader" title="'.trim($PACTS_cfg->getFieldDescription("Individual", "GenderCode")).'">';
    echo 'Individual Gender:</li>'."\n";
    echo '<li class="viewDetailsDataEdit">'."\n";
    echo "".$PACTS_cfg->getLookupTableHTML("GenderCode","Individual[GenderCode]",@$Indv['GenderCode'],"2")."\n";
    echo '</li>'."\n";
    echo '</ul>'."\n";

    echo '<ul>'."\n";
    echo '<li class="viewDetailsHeader" title="'.trim($PACTS_cfg->getFieldDescription("Individual", "MaritalStatusCode")).'">';
    echo 'Individual Marital Status:</li>'."\n";
    echo '<li class="viewDetailsDataEdit">'."\n";
    echo "".$PACTS_cfg->getLookupTableHTML("MaritalStatusCode","Individual[MaritalStatusCode]",@$Indv['MaritalStatusCode'],"3")."\n";
    echo '</li>'."\n";
    echo '</ul>'."\n";

    echo '<ul>'."\n";
    echo '<li class="viewDetailsHeader" title="'.trim($PACTS_cfg->getFieldDescription("Individual", "AgeRange")).'">';
    echo 'Age Range:</li>'."\n";
    echo '<li class="viewDetailsDataEdit">'."\n";
    echo "".$PACTS_cfg->getLookupTableHTML("AgeRange","Individual[AgeRange]",@$Indv['AgeRange'],"4")."\n";
    echo '</li>'."\n";
    echo '</ul>'."\n";

    echo '<ul>'."\n";
    echo '<li class="viewDetailsHeader" title="'.trim($PACTS_cfg->getFieldDescription("Individual", "WorkTypeCode")).'">';
    echo 'Work Type:</li>'."\n";
    echo '<li class="viewDetailsDataEdit">'."\n";
    echo "".$PACTS_cfg->getLookupTableHTML("WorkTypeCode","Individual[WorkTypeCode]",@$Indv['WorkTypeCode'],"5")."\n";
    echo '</li>'."\n";
    echo '</ul>'."\n";

    echo '<ul>'."\n";
    echo '<li class="viewDetailsHeader" title="'.trim($PACTS_cfg->getFieldDescription("Individual", "EducationalInstitutionName")).'">';
    echo 'Educational Institution:</li>'."\n";
    echo '<li class="viewDetailsDataEdit">'."\n";
    echo $PACTS_cfg->getLookupTableHTML("EducationalInstitutionName","Individual[EducationalInstitutionName]",@$Indv['EducationalInstitutionName'],"6");
    echo '</li>'."\n";
    echo '</ul>'."\n";

    echo '<ul>'."\n";
    echo '<li class="viewDetailsHeader" title="'.trim($PACTS_cfg->getFieldDescription("Individual", "ChurchIntroductionMethod")).'">';
    echo 'ChurchIntroductionMethod:</li>'."\n";
    echo '<li class="viewDetailsDataEdit">'."\n";
    echo$PACTS_cfg->getLookupTableHTML("ChurchIntroductionMethod","Individual[ChurchIntroductionMethod]",@$Indv['ChurchIntroductionMethod'],"7")."\n";
    echo '</li>'."\n";
    echo '</ul>'."\n";


    echo '<ul>'."\n";
    echo '<li class="viewDetailsHeader" >Filter Records By</li>';
    echo '<li class="viewDetailsDataEdit">'."\n";
    echo '<ul>'."\n";
    echo '<li title="'.trim($PACTS_cfg->getFieldDescription("Individual", "ChurchDirectoryIndicator")).'">';
    echo 'Church Directory Indicator';


    echo '<input type="radio" name="Individual_fltr[ChurchDirectory]" value="ALL"';
    if (isset($_POST['submitData']) AND @$Indv_fltr['ChurchDirectory']=="ALL") {
        echo ' checked="checked" ';
    }
    echo " />&nbsp;ALL";
    echo '</li>'."\n";
    echo '<li title="'.trim($PACTS_cfg->getFieldDescription("Individual", "ChurchDirectoryIndicator")).'" >';
    echo '<input type="radio" name="Individual_fltr[ChurchDirectory]"  value="Y"'."\n";
    if (!isset($_POST['submitData']) or @$Indv_fltr['ChurchDirectory']=="Y") {
        echo ' checked="checked" ';
    }
    echo ' />&nbsp;TRUE (Default)'."\n";
    echo '</li>'."\n";
    echo '<li>'."\n";
    echo '<input type="radio" name="Individual_fltr[ChurchDirectory]"  value="N"';
    if (isset($_POST['submitData']) AND @$Indv_fltr['ChurchDirectory']=="N") {
        echo ' checked="checked" ';
    }
    echo ' />&nbsp;FALSE'."\n";

    echo "</li>";
    echo "</ul>\n";
    echo "</li>";
    echo "</ul>\n";


    echo '<ul>'."\n";
    echo '<li class="viewDetailsHeader" >Filter Records By</li>';

    echo '<li class="viewDetailsDataEdit">'."\n";
    echo '<ul>'."\n";
    echo '<li class="viewDetailsDataEdit" title="'.trim($PACTS_cfg->getFieldDescription("Individual", "BaptismContactIndicator")).'">';
    echo 'Baptism Contact Indicator';
    echo "</li>";

    echo '<li><input type="radio" name="Individual_fltr[Baptism]" value="ALL"';
    if (!isset($_POST['submitData']) or (@$Indv_fltr['Baptism']=="ALL" )) {
        echo ' checked="checked" ';
    }
    echo " />&nbsp;ALL (Default)</li>";


    echo '<li title="'.trim($PACTS_cfg->getFieldDescription("Individual", "BaptismContactIndicator")).'" >';
    echo '<input type="radio" name="Individual_fltr[Baptism]" value="Y"';
    if (isset($_POST['submitData']) AND @$Indv_fltr['Baptism']=="Y"  ) {
        echo ' checked="checked" ';
    }
    echo ' />TRUE</li>'."\n";
    echo '<li>',"\n";


    echo '<input type="radio" name="Individual_fltr[Baptism]" value="N"';
    if (isset($_POST['submitData']) AND @$Indv_fltr['Baptism']=="N"  ) {
        echo ' checked="checked" ';
    }
    echo " />&nbsp;FALSE";
    echo '</li>';
    echo '</ul>'."\n";
    echo '</li>';
    echo '</ul>'."\n";

    echo '<div class="ReportMinorOptions">'."\n";


    if($ReportToFilter=="CSV_Fmly.php")
    {

        echo "<tr>\n";
        echo '<td colspan=3 title="'.trim($PACTS_cfg->getFieldDescription("Family", "OutOfAreaIndicator")).'">';
        echo '<center>Out Of Area Indicator</center>';
        echo "</td></tr><tr>";

        echo "<tr>\n";
        echo '<td width=30% title="Display all records" ><input type="radio" name="Family_fltr[OutOfArea]" value="ALL"';
        if (isset($_POST['submitData']) AND (@$Fmly_fltr['OutOfArea']=="ALL" )) {
            echo ' checked="checked" ';
        }
        echo ">&nbsp;ALL</td>";

        echo '<td title="'.trim($PACTS_cfg->getFieldDescription("Family", "OutOfAreaIndicator")).'" >';
        echo '<input type="radio" name="Family_fltr[OutOfArea]" value="Y"';
        if (isset($_POST['submitData']) AND @$Fmly_fltr['OutOfArea']=="Y"  ) {
            echo ' checked="checked" ';
        }
        echo ">TRUE</td><td>";

        echo '<input type="radio" name="Family_fltr[OutOfArea]" value="N"';
        if (!isset($_POST['submitData']) OR @$Fmly_fltr['OutOfArea']=="N"  ) {
            echo ' checked="checked" ';
        }
        echo ">&nbsp;FALSE (Default)";
        echo "</td>";
        echo "</tr>\n";
    }

    if(strpos($ReportToFilter,"ChurchDirectory")>0) {

        // if report = ChurchDirectory then

        echo '<ul>'."\n";
        echo '<li>'."\n";
        echo '<h3>Filter Report Display : <?php echo $ReportToFilter; ?></h3>'."\n";
        echo '</li>'."\n";
        echo '</ul>'."\n";

















  //      echo '<ul>'."\n";
  //      echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";
        echo '<ul>'."\n";
      echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";
          echo '<p class="floatleft">Show Private Addresses as XXX: &nbsp;</p>'."\n";
        echo '<p class="floatleftCB">'."\n";

        if(!$PACTS_cfg->getUserCanViewPrivate()) {
            echo '<input type="hidden" name="filterdisplay[ShowPrivateRA]" value="TRUE" >';
            echo '<input type="checkbox" name="filterdisplay[ShowPrivateRA_tmp]" value="TRUE"';
            echo ' disabled="disabled" '.' checked="checked" ';
        } else {
            echo '<input type="checkbox" name="filterdisplay[ShowPrivateRA]" value="TRUE"';
            if(@$Fltr['ShowPrivateRA']=="TRUE" or !$BsubmitInd) {
                echo ' checked="checked" ';
            }
        }
        echo ' />'."\n";
        echo '</p>'."\n";
        echo '</li>'."\n";
        echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";
        echo '<p class="floatleft">Show Private Phone Numbers as XXX:&nbsp;</p>'."\n";
        echo '<p class="floatleftCB">'."\n";

        if(!$PACTS_cfg->getUserCanViewPrivate()) {
            echo '<input type="hidden" name="filterdisplay[ShowPrivatePN]" value="TRUE" >';
            echo '<input type="checkbox" name="filterdisplay[ShowPrivatePN_tmp]" value="TRUE"';
            echo ' disabled="disabled" '.' checked="checked" ';
        } else {
            echo '<input type="checkbox" name="filterdisplay[ShowPrivatePN]" value="TRUE"';
            if(@$Fltr['ShowPrivatePN']=="TRUE" or !$BsubmitInd) {
                echo ' checked="checked" ';
            }
        }
        echo ' />'."\n";
        echo '</p>'."\n";
        echo '</li>'."\n";
//        echo '</ul>'."\n";
//        echo '</li>'."\n";
//        echo '</ul>'."\n";



//        echo '<ul>'."\n";
        echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";
//        echo '<ul>'."\n";
//        echo '<li>'."\n";
        echo '<p class="floatleft">Show Private Email Addresses as XXX:&nbsp;</p>'."\n";
        echo '<p class="floatleftCB">'."\n";

        if(!$PACTS_cfg->getUserCanViewPrivate()) {
            echo '<input type="hidden" name="filterdisplay[ShowPrivateEA]" value="TRUE" >';
            echo '<input type="checkbox" name="filterdisplay[ShowPrivateEA_tmp]" value="TRUE"';
            echo ' disabled="disabled" '.' checked="checked" ';
        } else {
            echo '<input type="checkbox" name="filterdisplay[ShowPrivateEA]" value="TRUE"';
            if(@$Fltr['ShowPrivateEA']=="TRUE" or !$BsubmitInd) {
                echo ' checked="checked" ';
            }
        }
        echo ' />'."\n";




        echo '</p>'."\n";
        echo '</li>'."\n";
        echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";

        echo '<p class="floatleft">Do NOT Show Any Private Data :&nbsp;</p>'."\n";
        echo '<p class="floatleftCB">'."\n";
        echo '<input type="checkbox" name="filterdisplay[HidePrivateData]" value="TRUE"';

        if(@$Fltr['HidePrivateData']=="TRUE" or !$BsubmitInd) {
            echo ' checked="checked" ';
        }
        echo ' />'."\n";
        echo '</p>'."\n";
        echo '</li>'."\n";
//        echo '</ul>'."\n";
//        echo '</li>'."\n";
//        echo '</ul>'."\n";

//        echo '<ul>'."\n";
        echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";
//        echo '<ul>'."\n";
//        echo '<li>'."\n";
        echo '<p class="floatleft">Show Individual\'s Role in family:</p>'."\n";
        echo '<p class="floatleftCB">'."\n";
        echo '<input type="checkbox" name="filterdisplay[ShowRole]" value="TRUE"';

        if(@$Fltr['ShowRole']==TRUE ) {
            echo ' checked="checked" ';
        }
        echo ' />'."\n";

        echo '</p>'."\n";
        echo '</li>'."\n";
        echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";

        echo '<p class="floatleft">Show Individual\'s Gender:</p>'."\n";
        echo '<p class="floatleftCB">'."\n";
        echo '<input type="checkbox" name="filterdisplay[ShowGender]" value="TRUE"';

        if(@$Fltr['ShowGender']==TRUE ) {
            echo ' checked="checked" ';
        }
        echo ' />'."\n";

        echo '</p>'."\n";
        echo '</li>'."\n";
//        echo '</ul>'."\n";
//        echo '</li>'."\n";
//        echo '</ul>'."\n";
//        echo '<ul>'."\n";
        echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";
//        echo '<ul>'."\n";
//        echo '<li>'."\n";
        echo '<p class="floatleft">Show Work Phone Numbers:&nbsp;</p>'."\n";
        echo '<p class="floatleftCB">'."\n";
        echo '<input type="checkbox" name="filterdisplay[ShowWrkPN]" value="TRUE"';

        if(@$Fltr['ShowWrkPN']==TRUE or !$BsubmitInd) {
            echo ' checked="checked" ';
        }
        echo ' />'."\n";

        echo '</p>'."\n";
        echo '</li>'."\n";
        echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";
        echo '<p class="floatleft">Show Work Email Addresses:</p>'."\n";
        echo '<p class="floatleftCB">'."\n";
        echo '<input type="checkbox" name="filterdisplay[ShowWrkEA]" value="TRUE"';

        if(@$Fltr['ShowWrkEA']==TRUE or !$BsubmitInd) {
            echo ' checked="checked" ';
        }
        echo ' />'."\n";

        echo '</p>'."\n";
        echo '</li>'."\n";
//        echo '</ul>'."\n";
//        echo '</li>'."\n";
//        echo '</ul>'."\n";

//        echo '<ul>'."\n";
        echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";
//        echo '<ul>'."\n";
//        echo '<li>'."\n";
        echo '<p class="floatleft">Show Mobile Phone Numbers:&nbsp;</p>'."\n";
        echo '<p class="floatleftCB">'."\n";
        echo '<input type="checkbox" name="filterdisplay[ShowMob]" value="TRUE"';

        if(@$Fltr['ShowMob']==TRUE or !$BsubmitInd) {
            echo ' checked="checked" ';
        }
        echo ' />'."\n";

        echo '</p>'."\n";
        echo '</li>'."\n";
        echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";
        echo '<p class="floatleft">Show Home Email Addresses:</p>'."\n";
        echo '<p class="floatleftCB">'."\n";
        echo '<input type="checkbox" name="filterdisplay[ShowHomeEA]" value="TRUE"';
        if(@$Fltr['ShowHomeEA']==TRUE or !$BsubmitInd) {
            echo ' checked="checked" ';
        }
        echo ' />'."\n";

        echo '</p>'."\n";
        echo '</li>'."\n";
//        echo '</ul>'."\n";
//        echo '</li>'."\n";
//        echo '</ul>'."\n";

 //       echo '<ul>'."\n";
        echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";
//        echo '<ul>'."\n";
//        echo '<li>'."\n";
        echo '<p class="floatleft">Show School Grade:&nbsp;</p>'."\n";
        echo '<p class="floatleftCB">'."\n";
        echo '<input type="checkbox" name="filterdisplay[ShowSchoolGde]" value="TRUE"';

        if(@$Fltr['ShowSchoolGde']==TRUE or !$BsubmitInd) {
            echo ' checked="checked" ';
        }
        echo ' />'."\n";

        echo '</p>'."\n";
        echo '</li>'."\n";
        echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";
        echo '<p class="floatleft">Show Family Photos:&nbsp;</p>'."\n";
        echo '<p class="floatleftCB">'."\n";
        echo '<input type="checkbox" name="filterdisplay[ShowFmlyPic]" value="TRUE"';

        if(@$Fltr['ShowFmlyPic']=="TRUE" ) {
            echo ' checked="checked" ';
        }
        echo ' />'."\n";

        echo '</p>'."\n";
        echo '</li>'."\n";
//        echo '</ul>'."\n";
//        echo '</li>'."\n";
//        echo '</ul>'."\n";

  //      echo '<ul>'."\n";
        echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";
//        echo '<ul>'."\n";
//        echo '<li>'."\n";
        echo '<p class="floatleft">Show Young Adult Indc:</p>'."\n";
        echo '<p class="floatleftCB">'."\n";

        echo '<input type="checkbox" name="filterdisplay[ShowYA]" value="TRUE"';

        if(@$Fltr['ShowYA']==TRUE or !$BsubmitInd) {
            echo ' checked="checked" ';
        }
        echo ' />'."\n";

        echo '</p>'."\n";
        echo '</li>'."\n";

    } // end if ChurchDirectory
//    echo '<ul>'."\n";
    echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";
    echo '<p class="floatleft">Show Page Numbers:</p>'."\n";
    echo '<p class="floatleftCB">'."\n";
    echo '<input type="checkbox" name="filterdisplay[ShowPageNum]" value="TRUE"'."\n";

    if(@$Fltr['ShowPageNum']==TRUE or !$BsubmitInd) {
        echo ' checked="checked" ';
    }

    echo ' />'."\n";
    echo '</p>'."\n";
    echo '</li>';
    echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";
    echo '<p class="floatleft">Show Title Page:</p>'."\n";
    echo '<p class="floatleftCB">'."\n";
    echo '<input type="checkbox" name="filterdisplay[ShowTitlePage]" value="TRUE"'."\n";
    if(@$Fltr['ShowTitlePage']==TRUE or !$BsubmitInd) {
        echo ' checked="checked" ';
    }
    echo ' />'."\n";
    echo '</p>'."\n";
    echo '</li>'."\n";
//    echo '</ul>'."\n";
//    echo '</li>'."\n";
//    echo '</ul>'."\n";
//    echo '<ul>'."\n";

    if(strtolower($ReportToFilter)==strtolower("GPAC_ChurchDirectory_A5_Landscape_booklet")) {

        echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";
//        echo '<ul>'."\n";
//        echo '<li>'."\n";
        echo '<p class="floatleft">Show Page Footer:&nbsp;</p>'."\n";
        echo '<p class="floatleftCB">'."\n";
        echo '<input type="checkbox" name="filterdisplay[ShowPageFooter]" value="TRUE"'."\n";

        if(@$Fltr['ShowPageFooter']==TRUE or !$BsubmitInd) {
            echo ' checked="checked" ';
        }
        echo ' />'."\n";
        echo '</p>'."\n";
        echo '</li>'."\n";
    }


    echo '<li class="viewDetailsDataEditMinorReportDetails">'."\n";
    echo '<p class="floatleft">Page Start Number:&nbsp;</p>'."\n";
    echo '<p class="floatleftCB">'."\n";
    echo '<select name="filterdisplay[StartPageNum]">'."\n";

    if(!strlen(@$Fltr['StartPageNum'])>0) {
        $Fltr['StartPageNum'] = 1;
    }
    for($i=-5; $i<10; $i++) {
        echo '<option value="'.$i.'" ';
        if(@$Fltr['StartPageNum']==$i) {
            echo ' selected="selected" ';
        }
        echo '>'.$i.'</option>'."\n";
    }
    echo '</select>'."\n";
    echo '</p>'."\n";
        echo '</li>'."\n";
        echo '</ul>'."\n";
    echo '</li>'."\n";
    echo '</ul>'."\n";


    echo '</div>'."\n";


    echo '<ul><li>'."\n";
    echo '<input type="hidden" name="filterdisplay[IgnoreMe]" value="TRUE" />'."\n";
    echo '<input type="submit" name="submitData" value="Generate Report" />'."\n";
    echo '</li></ul>'."\n";

    echo '</div>'."\n";
    echo '</form>'."\n";
}
echo '</div>'."\n";

?> 